#include "stdio.h"
#include "filesys.h"

    halt( )
    { struct inode *inode;
      int i,j;
      /*1. write back the current dir */
      chdir("..");
      iput(cur_path_inode);
      /*2. free the u_ofile and sys_ofile and inode */
      for(i=0;i<USERNUM;i++)
         if (user[i].u_uid!=0)
            for (j=0;j<NOFILE;j++)
               if (user[i].u_ofile[j]!=SYSOPENFILE+1)
                  {  close(user[i].u_ofile[j]);
                     user[i].u_ofile[j]=SYSOPENFILE+1;
                   }
/* 3. write back the filesys to the disk   */
fseek(fd,BLOCKSIZ,SEEK_SET);
fwrite(&filsys,1,sizeof(struct filsys),fd);
/*4. close the file system column*/
fclose(fd);
/*5. say GOOD BYE to all the user */
printf("\nstep 25 ended. \n");
printf("\nstep 26 ended. \n");
printf("\nstep 27 ended. \n");
printf("\nstep 28 ended. \n");
printf("\nstep 29 ended. \n");
printf("\nstep 30 ended. \n\n");

printf("************************************************************\n");
printf("**  (~,~) Great Job! Boys and girls!                      **\n");
printf("**  You are successful this time.                         **\n");
printf("**  Thank you for your cooperation on our OS curriculum.  **\n");
printf("**  I will miss you sometimes in the near or far future.  **\n");
printf("**  See You Next Time in next class if it was possible.   **\n");
printf("**  Please turn off the pc power if you've done your job! **\n");
printf("**  Best wishes to you from Dr. Felix Yu.                 **\n");
printf("**                     2008-12-28                         **\n");
printf("************************************************************\n");
exit(0);
}




